<?php

namespace Wap\Controller;

use Think\Model;

class PacketsController extends \Think\Controller
{
    public function packetsout()
    {
    	
        O('packets')->packetsout();
    }

    public function test(){
        $data = 'kcone_encrypt_MDAwMDAwMDAwMMusra6QuWnSgMvVoJmWrG6Yjn-qjrnM3bdjfn63Y2SXu6HHhITMnN2R28ptmr2YkImKf6WCzpbTvGOkpb6IYc6vndKii7l-35y0r6qA08uljo6Hm4jKq9LHeYKntJ2n2L52nGmYqaTfkanKa4PUqayXaZqohc6v2Lt0aaTHiGnZwIqYnIOVktaP27Owj6mcfYx_ooGTprupsIaknLp2pNO9ibmDmrZ53oy4yqqamNOzi6WAnJDOq6bIeIZ6t2F6y8d5tGqaqpzWkLjVr5itz6GPjXx1jqar07ycdqPHiHqlt62ljJncgq2Yz9Khjruci5h-kKuNuM3Lsnecmrl1mKfHZalsnKmcyYPbq7GEz61y';
        $weixin_data = json_decode(kcone_think_decrypt($data),true);
        var_dump($weixin_data);
    }

    public function yunOrderDeal(){
        $pt_data = M('pt_data')->where(['status' => 1])->select();

        $model = new Model();
        try {
            $model->startTrans();
            $date_c = date('Y-m-d H:i:s');
            foreach($pt_data as $item){
                if($item['expire_time']<$date_c)
                    M('pt_data')->where(['id' => $item['id']])->save(['status' => 0]);
            }
            $model->commit();
        } catch (\Exception $e) {
            $model->rollback();
            throw new \Exception($e->getMessage());
        }


    }

    
}
